﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Management/Manage.Master" %>
<%@ Import Namespace="CSI.Directory.Core.Model"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Edit Article
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
    $(document).ready(function() {

        $("a").removeClass("current");
        $("#users").addClass("current");
        var e = jQuery.Event("click");
        $("#users").trigger(e);
        $("#list-users").addClass("current");
        

    });
</script>
    <div class="content-box">
        <!-- Start Content Box -->
        <div class="content-box-header">
            <h3>
                Edit User</h3>
            
            <div class="clear">
            </div>
        </div>
        <!-- End .content-box-header -->
        <div class="content-box-content">
            <div class="tab-content default-tab" id="tab1">
        
    
   <form action="/Management/EditUser" name="form1" method="post">
    <fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
								
			
				<label>Name :
					<%=((User)ViewData["User"]).Name %>
				</label>	
					
			
            
            
				<label>Email :
					<%=((User)ViewData["User"]).Email %>
				</label>	
			
                <%if (((User)ViewData["User"]).Address != null){ %>
				    <label>Address :
					    <%=((User)ViewData["User"]).Address %><br />
					    <%=((User)ViewData["User"]).City %>,
					    <%=((User)ViewData["User"]).State %>
				    </label>	
                <%} %>
                <label>Phone :
					<%=((User)ViewData["User"]).Phone %>
				</label>
            
                <label>Package : 
					<%=((User)ViewData["User"]).Package %>
				</label>
            
                <label>Option  : 
					<%=((User)ViewData["User"]).Option %>
				</label>
             
                <label>Change Password  : 
					<input type="text" name="password" id="password" />
				</label>
            
             <input name="id" value="<%=((User)ViewData["User"]).Id %>" type="hidden" />
             <input type="button" onclick="return DoAjaxSubmit(this);" value="Save" class="button" />
             <div id="results"></div>
            </fieldset>
               </form>
               <div class="content-box-header">
            <h3>
                Listings</h3>
            
            <div class="clear">
            </div>
        </div>
        <!-- End .content-box-header -->
        <div class="content-box-content">
        <div id="Div2"></div>
            <div class="tab-content default-tab" id="Div1">
                
                <table>
                    <thead>
                        <tr>
                            <th>
                                Name
                            </th>
                            <th>
                                Create Date
                            </th>
                            
                        </tr>
                    </thead>
                    <tbody>
                         <%foreach (var l in (IList<Listing>) ViewData["Listings"])
                            {%>
                   
                        <tr>
                            <td>
                                <a href="/Management/EditListing/<%=l.Id %>"><%=l.Name %></a>
                            </td>
                            <td>
                                <%=l.CreateDate %>
                            </td>                            
                        </tr>
                        <%} %>
                    </tbody>
                </table>
            </div>
        
           </div>
           
            

    </div>
        </div>
    </div>
    
    <script type="text/javascript">
    
        function DoAjaxSubmit(btnClicked) {
            var form = $(btnClicked).parents('form');
            if ($("#password").val() == "") {
                $("#results").html("Please complete all fields").addClass("red");
                return false;
            }
            else {
                $("#results").html("");
                $.ajax({
                    type: "POST",
                    url: form.attr('action'), //'<%=ResolveUrl("~/register/go") %>',
                    data: form.serialize(),
                    error: function(xhr, status, error) {
                    },
                    success: function(response) {
                        if (response != null) {
                            if (!response.Successful) {
                                $("#results").html("An error occurred: " + response.Exception).addClass("red");
                                return false;
                            }
                            else {
                                $("#results").html("User updated").addClass("green");
                                
                            }
                        }
                    }
                });
            }
            return false;
        }
    </script>

</asp:Content>
